<?php
/**
 * Introduction: 活动
 * @author: 杨陈鹏
 * @email: yangchenpeng@cdlinglu.com
 */

namespace App\Controller\Activity;


use Think\Controller;

class IndexController extends Controller
{
    /**
     * Introduction: 活动列表
     * @author: 杨陈鹏
     * @email: yangchenpeng@cdlinglu.com
     */

    /*

    var data = {

            page: 2,
            nums: 20,
            where: 'ing' //传入ing为进行中,传入其他或不传为结束的活动

    }

     */
    public function lists()
    {

        $page = intval(I('post.page',1));

        $nums = intval(I('post.nums',20));

        $where = I('post.where');

        if ($where == 'ing') {

            $where = "end_time >= ".NOW_TIME;

        } else {

            $where = "end_time < ".NOW_TIME;

        }


        $logic = D('Common/Activity','Logic');

        $fields = 'id,title,thumb,description,images,persons,create_time,end_time,views,shares,description';

        outPut($logic::getData($where, $fields,'create_time desc', $page, $nums));

    }
    /**
     * Introduction: 获取秀图详情
     * @author: 杨陈鹏
     * @email: yangchenpeng@cdlinglu.com
     */
    /*

    var data = {

            data:{'activity_show_id': 343}

    }
     */
    public function showDetail()
    {

        $data = I('post.data');

        $logic = D('Common/Activity','Logic');

        outPut($logic::showDetail($data['activity_show_id'],'*'));

    }
    /**
     * Introduction: 获取活动详情
     * @author: 杨陈鹏
     * @email: yangchenpeng@cdlinglu.com
     */
    public function detail()
    {

        $data = I('post.data');

        $activity_id = $data['activity_id'];

        $logic = D('Common/Activity','Logic');

        outPut($logic::getOneData($activity_id));


    }
    /**
     * Introduction: 秀图点赞
     * @author: 杨陈鹏
     * @email: yangchenpeng@cdlinglu.com
     */
    public function showLike()
    {

        $data = I('post.data');

        $activity_id = $data['activity_show_id'];

        $logic = D('Common/Activity','Logic');

        outPut($logic::like($activity_id),true);


    }
    /**
     * Introduction: 秀图评论点赞
     * @author: 杨陈鹏
     * @email: yangchenpeng@cdlinglu.com
     */
    public function showCommentLike()
    {

        $data = I('post.data');

        $show_comment_id = $data['show_comment_id'];

        $logic = D('Common/Activity','Logic');

        outPut($logic::showCommentLike($show_comment_id));


    }
    /**
     * Introduction: 秀图列表
     * @author: 杨陈鹏
     * @email: yangchenpeng@cdlinglu.com
     */
    /*
    var data = {

        page: 1,
        nums: 20,
        data:{
            order:{'column': 'likes','type':'desc'},
            is_images: 'images'//如果传入,则只返回图片
        }
    }
*/
    public function showLists()
    {

        $data = I('post.data');

        $logic = D('Common/Activity','Logic');

        $activity_id = $data['activity_id'];

        $page = I('post.page');
        $nums = I('post.nums');

        $order = $data['order']['column'] ? $data['order']['column'] : 'create_time' ;

        $order .= $data['order']['type'] ? ' '.$data['order']['type'] : ' desc' ;

        $is_images = false;
        if($data['is_images'] == 'images')
            $is_images = true;

        outPut($logic::showLists($activity_id,'*', $order,$page, $nums,$is_images),true);


    }
    /**
     * Introduction: 获取秀图评论列表
     * @author: 杨陈鹏
     * @email: yangchenpeng@cdlinglu.com
     */
    /*

    var data = {

            data:{

                activity_show_id:232

            }

    }


     */
    public function commentLists()
    {


        $data = I('post.data');

        $activity_show_id = $data['activity_show_id'];

        $logic = D('Common/Activity','Logic');

        outPut($logic::showCommentLists($activity_show_id));

    }


}